import request from "@/utils/request";
import { userUrl, userCheckUrl } from "./url";

export async function getProvList() {
  return request({
    url: `${userUrl}/sysDepart/queryTreeList`,
    method: "GET",
  });
  /*  return {
    success: true,
    message: "",
    code: 0,
    result: [
      {
        key: "1720341926555684866",
        value: "1720341926555684866",
        title: "应用建设",
        isLeaf: true,
        id: "1720341926555684866",
        parentId: "",
        departName: "应用建设",
        departNameEn: null,
        departNameAbbr: null,
        departOrder: 0,
        description: null,
        orgCategory: "1",
        orgType: "1",
        orgCode: "A03",
        mobile: null,
        fax: null,
        address: null,
        memo: null,
        status: null,
        delFlag: "0",
        qywxIdentifier: null,
        createBy: "admin",
        createTime: "2023-11-03 15:27:32",
        updateBy: null,
        updateTime: null,
        directorUserIds: null,
        children: null,
      },
      {
        key: "6d35e179cd814e3299bd588ea7daed3f",
        value: "6d35e179cd814e3299bd588ea7daed3f",
        title: "北京卓尔互动",
        isLeaf: false,
        id: "6d35e179cd814e3299bd588ea7daed3f",
        parentId: "",
        departName: "北京卓尔互动",
        departNameEn: null,
        departNameAbbr: null,
        departOrder: 0,
        description: null,
        orgCategory: "1",
        orgType: "1",
        orgCode: "A02",
        mobile: null,
        fax: null,
        address: null,
        memo: null,
        status: null,
        delFlag: "0",
        qywxIdentifier: null,
        createBy: "admin",
        createTime: "2019-02-26 16:36:39",
        updateBy: "admin",
        updateTime: "2020-05-02 18:21:22",
        directorUserIds: null,
        children: [
          {
            key: "5159cde220114246b045e574adceafe9",
            value: "5159cde220114246b045e574adceafe9",
            title: "研发部",
            isLeaf: true,
            id: "5159cde220114246b045e574adceafe9",
            parentId: "6d35e179cd814e3299bd588ea7daed3f",
            departName: "研发部",
            departNameEn: null,
            departNameAbbr: null,
            departOrder: 0,
            description: null,
            orgCategory: "1",
            orgType: "2",
            orgCode: "A02A02",
            mobile: null,
            fax: null,
            address: null,
            memo: null,
            status: null,
            delFlag: "0",
            qywxIdentifier: null,
            createBy: "admin",
            createTime: "2019-02-26 16:44:38",
            updateBy: "admin",
            updateTime: "2019-03-07 09:36:53",
            directorUserIds: null,
            children: null,
          },
          {
            key: "a7d7e77e06c84325a40932163adcdaa6",
            value: "a7d7e77e06c84325a40932163adcdaa6",
            title: "财务部",
            isLeaf: true,
            id: "a7d7e77e06c84325a40932163adcdaa6",
            parentId: "6d35e179cd814e3299bd588ea7daed3f",
            departName: "财务部",
            departNameEn: null,
            departNameAbbr: null,
            departOrder: 0,
            description: null,
            orgCategory: "1",
            orgType: "2",
            orgCode: "A02A01",
            mobile: null,
            fax: null,
            address: null,
            memo: null,
            status: null,
            delFlag: "0",
            qywxIdentifier: null,
            createBy: "admin",
            createTime: "2019-02-26 16:36:47",
            updateBy: "admin",
            updateTime: "2022-10-14 18:57:56",
            directorUserIds: null,
            children: null,
          },
        ],
      },
      {
        key: "c6d7cb4deeac411cb3384b1b31278596",
        value: "c6d7cb4deeac411cb3384b1b31278596",
        title: "北京国炬软件",
        isLeaf: false,
        id: "c6d7cb4deeac411cb3384b1b31278596",
        parentId: "",
        departName: "北京国炬软件",
        departNameEn: null,
        departNameAbbr: null,
        departOrder: 0,
        description: null,
        orgCategory: "1",
        orgType: "1",
        orgCode: "A01",
        mobile: null,
        fax: null,
        address: null,
        memo: null,
        status: null,
        delFlag: "0",
        qywxIdentifier: null,
        createBy: "admin",
        createTime: "2019-02-11 14:21:51",
        updateBy: "admin",
        updateTime: "2020-05-02 18:21:27",
        directorUserIds: null,
        children: [
          {
            key: "1582683631414632450",
            value: "1582683631414632450",
            title: "销售公关岗位",
            isLeaf: true,
            id: "1582683631414632450",
            parentId: "c6d7cb4deeac411cb3384b1b31278596",
            departName: "销售公关岗位",
            departNameEn: null,
            departNameAbbr: null,
            departOrder: 0,
            description: null,
            orgCategory: "3",
            orgType: "2",
            orgCode: "A01A06",
            mobile: null,
            fax: null,
            address: null,
            memo: null,
            status: null,
            delFlag: "0",
            qywxIdentifier: null,
            createBy: "admin",
            createTime: "2022-10-19 18:42:37",
            updateBy: null,
            updateTime: null,
            directorUserIds: null,
            children: null,
          },
          {
            key: "4f1765520d6346f9bd9c79e2479e5b12",
            value: "4f1765520d6346f9bd9c79e2479e5b12",
            title: "市场部",
            isLeaf: true,
            id: "4f1765520d6346f9bd9c79e2479e5b12",
            parentId: "c6d7cb4deeac411cb3384b1b31278596",
            departName: "市场部",
            departNameEn: null,
            departNameAbbr: null,
            departOrder: 0,
            description: null,
            orgCategory: "1",
            orgType: "2",
            orgCode: "A01A03",
            mobile: null,
            fax: null,
            address: null,
            memo: null,
            status: null,
            delFlag: "0",
            qywxIdentifier: null,
            createBy: "admin",
            createTime: "2019-02-20 17:15:34",
            updateBy: "admin",
            updateTime: "2019-02-26 16:36:18",
            directorUserIds: null,
            children: null,
          },
          {
            key: "57197590443c44f083d42ae24ef26a2c",
            value: "57197590443c44f083d42ae24ef26a2c",
            title: "研发部",
            isLeaf: false,
            id: "57197590443c44f083d42ae24ef26a2c",
            parentId: "c6d7cb4deeac411cb3384b1b31278596",
            departName: "研发部",
            departNameEn: null,
            departNameAbbr: null,
            departOrder: 0,
            description: null,
            orgCategory: "1",
            orgType: "2",
            orgCode: "A01A05",
            mobile: null,
            fax: null,
            address: null,
            memo: null,
            status: null,
            delFlag: "0",
            qywxIdentifier: null,
            createBy: "admin",
            createTime: "2019-02-21 16:14:41",
            updateBy: "admin",
            updateTime: "2019-03-27 19:05:49",
            directorUserIds: null,
            children: [
              {
                key: "63775228b7b041a99825f79760590b7d",
                value: "63775228b7b041a99825f79760590b7d",
                title: "研发经理",
                isLeaf: true,
                id: "63775228b7b041a99825f79760590b7d",
                parentId: "57197590443c44f083d42ae24ef26a2c",
                departName: "研发经理",
                departNameEn: null,
                departNameAbbr: null,
                departOrder: 0,
                description: null,
                orgCategory: "3",
                orgType: "3",
                orgCode: "A01A05A01",
                mobile: null,
                fax: null,
                address: null,
                memo: null,
                status: null,
                delFlag: "0",
                qywxIdentifier: null,
                createBy: "admin",
                createTime: "2020-05-02 15:29:09",
                updateBy: null,
                updateTime: null,
                directorUserIds: null,
                children: null,
              },
            ],
          },
          {
            key: "67fc001af12a4f9b8458005d3f19934a",
            value: "67fc001af12a4f9b8458005d3f19934a",
            title: "财务部",
            isLeaf: true,
            id: "67fc001af12a4f9b8458005d3f19934a",
            parentId: "c6d7cb4deeac411cb3384b1b31278596",
            departName: "财务部",
            departNameEn: null,
            departNameAbbr: null,
            departOrder: 0,
            description: null,
            orgCategory: "1",
            orgType: "2",
            orgCode: "A01A04",
            mobile: null,
            fax: null,
            address: null,
            memo: null,
            status: null,
            delFlag: "0",
            qywxIdentifier: null,
            createBy: "admin",
            createTime: "2019-02-21 16:14:35",
            updateBy: "admin",
            updateTime: "2019-02-25 12:49:41",
            directorUserIds: null,
            children: null,
          },
        ],
      },
    ],
    timestamp: 1722223873175,
  };*/
}

export async function addData(params) {
  // console.log(params, "新增操作参数");
  return request({
    url: `${userUrl}/user/add`,
    method: "POST",
    data: params,
  });
  /*  return {
    success: true,
    message: "删除成功!",
    code: 200,
    result: "删除成功!",
    timestamp: 1720688633000,
  };*/
}

export async function editData(params) {
  // console.log(params, "修改操作参数");
  return request({
    url: `${userUrl}/user/edit`,
    method: "PUT",
    data: params,
  });
  /*  return {
    success: true,
    message: "删除成功!",
    code: 200,
    result: "删除成功!",
    timestamp: 1720688633000,
  };*/
}
//删除
export async function deleteData(params) {
  // console.log(params, "删除操作参数");
  let id = params.id === "delete" ? "id" : "ids";
  return request({
    url: `${userUrl}/user/${params.id}?${id}=${params.deleteId}`,
    method: "DELETE",
  });
  /*  return {
    success: true,
    message: "删除成功!",
    code: 200,
    result: "删除成功!",
    timestamp: 1720688633000,
  };*/
}

export async function getTableBody(params) {
  // console.log(params, "查询参数");

  return request({
    url: `${userUrl}/user/listAll`,
    method: "GET",
    params: params,
  });
  /*  return {
    success: true,
    message: "",
    code: 0,
    result: {
      records: [
        {
          id: "1818467035816366081",
          username: "ceshiApiADd",
          realname: "朱ADDDDD",
          avatar: null,
          birthday: null,
          sex: null,
          email: "845269543@qq.com",
          phone: "15963252365",
          orgCode: null,
          loginTenantId: null,
          orgCodeTxt: "销售公关岗位",
          selectedroles: "1169504891467464705",
          status: 1,
          delFlag: 0,
          workNo: "945616",
          post: "",
          telephone: null,
          createBy: "admin",
          createTime: "2024-07-31 10:01:41",
          updateBy: "admin",
          updateTime: "2024-07-31 10:04:00",
          activitiSync: 1,
          userIdentity: 1,
          departIds: "",
          relTenantIds: "",
          clientId: null,
          homePath: null,
          postText: null,
          bpmStatus: null,
          izBindThird: false,
          provinceCode: null,
          eparchyCode: null,
          cityCode: null,
          rightClass: null,
          departId: null,
          userType: "0",
          status_dictText: "正常",
        },
        {
          id: "1818467035818856366081",
          username: "ceshiApiADd",
          realname: "朱A44DDDDD",
          avatar: null,
          birthday: null,
          sex: null,
          email: "845269543@qq.com",
          phone: "15963252365",
          orgCode: null,
          loginTenantId: null,
          orgCodeTxt: "销售公关岗位",
          selectedroles: "1169504891467464705",
          status: 1,
          delFlag: 0,
          workNo: "945616",
          post: "",
          telephone: null,
          createBy: "admin",
          createTime: "2024-07-31 10:01:41",
          updateBy: "admin",
          updateTime: "2024-07-31 10:04:00",
          activitiSync: 1,
          userIdentity: 1,
          departIds: "",
          relTenantIds: "",
          clientId: null,
          homePath: null,
          postText: null,
          bpmStatus: null,
          izBindThird: false,
          provinceCode: null,
          eparchyCode: null,
          cityCode: null,
          rightClass: null,
          departId: null,
          userType: "0",
          status_dictText: "正常",
        },
      ],
      total: 12,
      size: 10,
      current: 1,
      orders: [],
      optimizeCountSql: true,
      searchCount: true,
      maxLimit: null,
      countId: null,
      pages: 2,
    },
    timestamp: 1722391863800,
  };*/
}
//获取角色下拉信息
export async function getSelectList() {
  return request({
    url: `${userUrl}/role/queryallNoByTenant`,
    method: "GET",
  });

  /*  return {
    success: true,
    message: "",
    code: 0,
    result: [
      {
        id: "1169504891467464705",
        roleName: "第三方登录角色",
        roleCode: "third_role",
        description: "第三方登录角色",
        createBy: "admin",
        createTime: "2019-09-05 14:57:49",
        updateBy: "admin",
        updateTime: "2020-05-02 18:20:58",
        tenantId: 0,
      },
      {
        id: "1260924539346472962",
        roleName: "财务出纳",
        roleCode: "caiwu",
        description: null,
        createBy: "admin",
        createTime: "2020-05-14 21:26:52",
        updateBy: null,
        updateTime: null,
        tenantId: 0,
      },
    ],
    timestamp: 1722394371523,
  };*/
}
export async function checkCode(params) {
  // console.log(params, "用户账号校验操作参数");
  return request({
    url: `${userCheckUrl}`,
    method: "GET",
    params: params,
    mark: true,
  });

  /*  return {
    success: false,
    message: "该值不可用，系统中已存在！",
    code: 200,
    result: null,
    timestamp: 1721698656796,
  };*/
}
export async function changePassWord(params) {
  // console.log(params, "修改密码操作参数");
  return request({
    url: `${userUrl}/user/changePassword`,
    method: "PUT",
    data: params,
  });

  /*  return {
    success: false,
    message: "该值不可用，系统中已存在！",
    code: 200,
    result: null,
    timestamp: 1721698656796,
  };*/
}
export async function getAuth(params) {
  return request({
    url: `${userUrl}/dataPermissions/queryTreeList`,
    method: "GET",
    params: params,
  });
  /*  let result = [
    [
      {
        label: "维度管理",
        value: "dimensionManagement",
      },
      {
        label: "新增",
        value: "dimensionManagement:add",
      },
      {
        label: "删除",
        value: "dimensionManagement:delete",
      },
    ],
    [
      {
        label: "用户管理",
        value: "userManage",
      },
      {
        label: "新增",
        value: "userManage:add",
      },
      {
        label: "修改",
        value: "userManage:edit",
      },
      {
        label: "新增",
        value: "userManage:delete",
      },
    ],
    [
      {
        label: "新增",
        value: "roleManage:add",
      },
      {
        label: "修改",
        value: "roleManage:edit",
      },
      {
        label: "新增",
        value: "roleManage:delete",
      },
    ],
  ];
  result = result.map((item) => JSON.stringify(item));
  return {
    success: false,
    message: "该值不可用，系统中已存在！",
    code: 200,
    result: result,
    timestamp: 1721698656796,
  };*/
}
export async function getUserInfo() {
  return request({
    url: `${userUrl}/user/getUserInfo`,
    method: "GET",
  });

  /*  return {
    success: false,
    message: "该值不可用，系统中已存在！",
    code: 200,
    result: {
      userInfo: {
        id: "e9ca23d68d884d4ebb19d07889727dae",
      },
    },
  };*/
}
export async function queryUserRole(params) {
  //参数userid
  return request({
    url: `${userUrl}/user/queryUserRole`,
    method: "GET",
    params: params,
  });

  /*  return {
    success: false,
    message: "该值不可用，系统中已存在！",
    code: 0,
    result: ["1818939516552142849", "1818931512272371714"],
  };*/
}
export async function frozenBatch(params) {
  //参数userid
  return request({
    url: `${userUrl}/user/frozenBatch`,
    method: "PUT",
    data: params,
  });

  /*  return {
    success: false,
    message: "该值不可用，系统中已存在！",
    code: 200,
    result: ["1818939516552142849", "1818931512272371714"],
  };*/
}
